package cn.bugDance.domain.activity.service.policy.impl;

import cn.bugDance.domain.activity.model.aggregate.ActivitySkuOrderAggregate;
import cn.bugDance.domain.activity.model.valobj.ActivitySkuOrderStateVO;
import cn.bugDance.domain.activity.model.valobj.TradeTypeVO;
import cn.bugDance.domain.activity.repository.IActivityRepository;
import cn.bugDance.domain.activity.service.policy.ITradePolicy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


import javax.annotation.Resource;

@Component("rebate_no_pay")
@Slf4j
public class RebateNoPayTradePolicy implements ITradePolicy {

    @Resource
    private IActivityRepository activityRepository;

    @Override
    public void trade(ActivitySkuOrderAggregate activitySkuOrderAggregate) {
        activitySkuOrderAggregate.getActivitySkuOrderEntity().setTradeType(TradeTypeVO.rebate_no_pay);
        activitySkuOrderAggregate.getActivitySkuOrderEntity().setState(ActivitySkuOrderStateVO.COMPLETED);
        activityRepository.saveOrder(activitySkuOrderAggregate);
    }
}
